import { GSprite } from "../../../../com/mui/controls/GSprite";
import { GImageBitmap } from "../../../../com/mui/controls/GImageBitmap";
import { ImagesConst } from "../../resource/ImagesConst";
import { GameDefConfig } from "../../resource/GameDefConfig";
import { Language } from "../../../../extend/language/Language";
import { ToolTipsManager } from "../../../../com/mui/manager/ToolTipsManager";
type int = number;
//class WuXingPropertyDistribution
    
    export  class WuXingPropertyDistribution extends GSprite
    {
        constructor()
        {
            super();
            this._centerPoint = new Object /* flash.geom.Point */(74, 75);
            this._wuXingMax = 1000;
            this._wuXingPoints = [new Object /* flash.geom.Point */(74, 30), new Object /* flash.geom.Point */(118, 61), new Object /* flash.geom.Point */(102, 109), new Object /* flash.geom.Point */(42, 108), new Object /* flash.geom.Point */(30, 63)];
            this._lineColor = [16357157, 4912947, 1746938, 14947541, 16200496];
            this._curWuXingPoints = [new Object /* flash.geom.Point */(), new Object /* flash.geom.Point */(), new Object /* flash.geom.Point */(), new Object /* flash.geom.Point */(), new Object /* flash.geom.Point */()];
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=new GImageBitmap(ImagesConst.WuXingPropertyDistributionBg, 0, 0);
            this.addChild(loc1);
            this._fillSp = new Object /* flash.display.Sprite */();
            this._fillSp.cacheAsBitmap = true;
            this.addChild(this._fillSp);
            this._lineSp = new Object /* flash.display.Sprite */();
            this._lineSp.cacheAsBitmap = true;
            this._lineSp.mouseEnabled = false;
            this.addChild(this._lineSp);
            var loc2=0;
            while (loc2 < 5) 
            {
                this._lineSp.graphics.moveTo(this._centerPoint.x, this._centerPoint.y);
                this._lineSp.graphics.lineStyle(1.5, this._lineColor[loc2], 0.6);
                this._lineSp.graphics.lineTo(flash.geom.Point(this._wuXingPoints[loc2]).x, flash.geom.Point(this._wuXingPoints[loc2]).y);
                ++loc2;
            }
            return;
        }

        /* internal  */set wuXingMaxAndColor(arg1: Array<any>)
        {
            var loc2=null;
            var loc1=Math.max(arg1[0], arg1[1], arg1[2], arg1[3], arg1[4]);
            var loc3=0;
            while (loc3 < 5) 
            {
                loc2 = GameDefConfig.instance.getItem("wuXingPropertyDistribution", loc3);
                if (loc2) 
                {
                    if (loc1 >= int(loc2.text1) && loc1 <= int(loc2.text2)) 
                    {
                        this._wuXingMax = int(loc2.text2);
                        this._color = loc2.value;
                        break;
                    }
                }
                ++loc3;
            }
            return;
        }

        public set data(arg1: Array<any>)
        {
            var loc2=NaN;
            var loc3=NaN;
            var loc4=null;
            var loc5=null;
            var loc6=0;
            var loc7=0;
            var loc1="";
            var loc8=arg1.length;
            this.wuXingMaxAndColor = arg1;
            loc7 = 0;
            while (loc7 < loc8) 
            {
                loc4 = this._wuXingPoints[loc7] as Object /* flash.geom.Point */;
                if (this._centerPoint.x > loc4.x) 
                {
                    loc2 = this._centerPoint.x - Math.abs(this._centerPoint.x - loc4.x) * arg1[loc7] / this._wuXingMax;
                }
                else if (this._centerPoint.x < loc4.x) 
                {
                    loc2 = this._centerPoint.x + Math.abs(this._centerPoint.x - loc4.x) * arg1[loc7] / this._wuXingMax;
                }
                if (loc4.x - this._centerPoint.x != 0) 
                {
                    loc3 = (loc2 - this._centerPoint.x) * (loc4.y - this._centerPoint.y) / (loc4.x - this._centerPoint.x) + this._centerPoint.y;
                }
                else 
                {
                    loc2 = this._centerPoint.x;
                    if (this._wuXingMax - arg1[loc7] != 0) 
                    {
                        loc3 = this._centerPoint.y - (this._centerPoint.y - loc4.y) * arg1[loc7] / this._wuXingMax;
                    }
                    else 
                    {
                        loc3 = loc4.y;
                    }
                }
                (loc5 = this._curWuXingPoints[loc7] as Object /* flash.geom.Point */).x = loc2;
                loc5.y = loc3;
                ++loc7;
            }
            this._fillSp.graphics.clear();
            this._fillSp.graphics.moveTo(flash.geom.Point(this._curWuXingPoints[0]).x, flash.geom.Point(this._curWuXingPoints[0]).y);
            this._fillSp.graphics.beginFill(this._color, 0.5);
            loc7 = 0;
            while (loc7 < loc8) 
            {
                loc1 = loc1 + (GameDefConfig.instance.getMagicWeaponPropertyName(22 + loc7) + arg1[loc7] + "<br>");
                loc6 = (loc7 + 1) % 5;
                this._fillSp.graphics.lineTo(flash.geom.Point(this._curWuXingPoints[loc6]).x, flash.geom.Point(this._curWuXingPoints[loc6]).y);
                ++loc7;
            }
            loc1 = loc1 + Language.getString(28027);
            this._fillSp.graphics.endFill();
            ToolTipsManager.unregister(this);
            ToolTipsManager.register(this, null, loc1);
            return;
        }

        public set wuXingMax(arg1: int)
        {
            this._wuXingMax = arg1;
            return;
        }

        public clean(): void
        {
            this._fillSp.graphics.clear();
            ToolTipsManager.unregister(this);
            return;
        }

        /* internal */ /* var */_lineSp: Object /* flash.display.Sprite */;

        /* internal */ /* var */_fillSp: Object /* flash.display.Sprite */;

        /* internal */ /* var */_wuXingMax: int;

        /* internal */ /* var */_color: int;

        /* internal */ /* var */_centerPoint: Object /* flash.geom.Point */;

        /* internal */ /* var */_wuXingPoints: Array<any>;

        /* internal */ /* var */_lineColor: Array<any>;

        /* internal */ /* var */_curWuXingPoints: Array<any>;
    }
